package dynamicprogramming;

class Solution746 {
    public static void main(String[] args) {
        Solution746 solution746 = new Solution746();
        System.out.println(solution746.minCostClimbingStairs(new int[]{10,15,20}));
    }
    // 第一步要支付费用
    public int minCostClimbingStairs(int[] cost) {
        int a = 0;
        int b = 0;
        int c = 0;
        for (int i = 2; i <= cost.length; i++) {
            c = Math.min(a +cost[i-2], b+ cost[i-1]);
            a = b;
            b = c;
        }
        return c;
    }
}